import request from '@/utils/request'
import { getToken } from '@/utils/auth'

export function queryAllStore(query) {
  return request({
    url: '/wxh-cloud-rest/rest/' + getToken() + '/pas/store/queryAllStore',
    method: 'get',
    params: query
  })
}

export function getUserByName(name) {
  return request({
    url: '/wxh-cloud-rest/rest/' + getToken() + '/pas/store/getUserByName?userName=' + name + '',
    method: 'get'
  })
}

export function saveStore(formData) {
  return request({
    url: '/wxh-cloud-rest/rest/' + getToken() + '/pas/store/saveStore',
    method: 'post',
    data: formData,
    headers: { 'Content-Type': 'multipart/form-data;charset=UTF-8' }
  })
}

export function updateStore(formData) {
  return request({
    url: '/wxh-cloud-rest/rest/' + getToken() + '/pas/store/updateStore',
    method: 'post',
    data: formData
  })
}

export function deleteStoreByStoreId(formData) {
  console.warn(formData.get('storeId'))
  console.warn(formData.get('deleteFlag'))
  return request({
    url: '/wxh-cloud-rest/rest/' + getToken() + '/pas/store/deleteStoreByStoreId',
    method: 'delete',
    data: formData
  })
}

export function queryWarehouseByWarehouseName(warehouseName) {
  return request({
    url: '/wxh-cloud-rest/rest/' + getToken() + '/pas/warehouse/queryWarehouseByWarehouseName?deleteFlag=N&warehouseName=' + warehouseName + '',
    method: 'get'
  })
}

export function orderDetailList(query) {
  return request({
    url: '/wxh-cloud-rest/rest/' + getToken() + '/pas/mallOrderItem/orderDetailList',
    method: 'get',
    params: query
  })
}

export function download(query) {
  return request({
    url: '/wxh-cloud-rest/rest/' + getToken() + '/pas/mallOrderItem/downloadOrder',
    method: 'get',
    params: query
  })
}
